package com.qys.livesMall.security.interceptor.core;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.i18n.LocaleContextHolder;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.HandlerInterceptor;

import java.util.Locale;

import static com.qys.livesMall.common.constants.SysConstants.AUTHORIZATION;


@Slf4j
@Order(2)
public class RequestInterceptor implements HandlerInterceptor {
    //handle 前

    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        log.debug("***********************执行了header拦截器*************************");
        response.setHeader("Access-Control-Allow-Origin", "*");

        response.setHeader("Access-Control-Allow-Headers", "X-Token,Content-Type,authorization");

        response.setHeader("Access-Control-Allow-Credentials", "true");

        response.setHeader("Access-Control-Allow-Methods", "GET,POST,PUT,DELETE,OPTIONS");

        response.setHeader("Access-Control-Max-Age", "3600");
        return true;

    }


}

